package com.example.software.controller;

import com.example.software.entity.FAQ;
import com.example.software.service.FAQService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/faq")  // 增加/api前缀
public class FAQController {
    @Autowired
    private FAQService faqService;

    @GetMapping
    public List<FAQ> getAllFAQ() {
        return faqService.getAllFAQ();
    }

    @PostMapping
    public boolean createFAQ(@RequestBody FAQ faq) {
        return faqService.save(faq);
    }

    @PutMapping("/{id}")
    public boolean editFAQ(@PathVariable Integer id, @RequestBody FAQ faq) {
        faq.setId(id);
        return faqService.updateById(faq);
    }

    @DeleteMapping("/{id}")
    public boolean deleteFAQ(@PathVariable Integer id) {
        return faqService.removeById(id);
    }
}